﻿using Hangfire;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Zocono.WCS.HangfireHost.Hangfire
{
    // HFJobActivator.cs

    public class HFJobActivator : JobActivator
    {
        readonly IServiceScopeFactory _serviceScopeFactory;
        public HFJobActivator(IServiceScopeFactory serviceScopeFactory)
        {
            _serviceScopeFactory = serviceScopeFactory;
        }
        public override JobActivatorScope BeginScope(JobActivatorContext context)
        {
            return new HFJobActivatorScope(_serviceScopeFactory.CreateScope());
        }
    }
}
